package com.taiyuan.tongcheng.ui;

import org.kymjs.kjframe.ui.BindView;
import org.kymjs.kjframe.ui.ViewInject;
import org.kymjs.kjframe.utils.StringUtils;

import com.taiyuan.tongcheng.util.TcUtil;
import com.tytc56.user.R;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

/**
 * 
* @Description 搬家联系人信息输入
* @author wzq
* @date 2015-9-22 下午1:03:18
* @update (date)
* @version V1.0
 */
public class InputTelActivitity extends BaseActivity{
//	initwidget
	@BindView(id=R.id.etv_connect_name)
	private EditText staConnectName;
	@BindView(id=R.id.etv_connect_tel)
	private EditText staConnectTel;
	@BindView(id=R.id.btn_sub,click=true)
	private Button subBtn;
	
	
	@Override
	public void setRootView() {
		super.setRootView();
		setContentView(R.layout.activity_input_tel);
	}
    
	@Override
	public void initWidget() {
		super.initWidget();
		initView();
		topTv.setText("搬家人信息确认");
		rightTv.setVisibility(View.GONE);
		staConnectName.setText(getIntent().getStringExtra(MovingActivity.TAG_MOVING_CONNECT_NAME));
		staConnectTel.setText(getIntent().getStringExtra(MovingActivity.TAG_MOVING_CONNECT_TEL));
	}
	
	@Override
	public void widgetClick(View v) {
		super.widgetClick(v);
		switch (v.getId()) {
		case R.id.btn_sub:
			if(checkInput()){
				getIntent().putExtra(MovingActivity.TAG_MOVING_CONNECT_TEL, staConnectTel.getText().toString());
				getIntent().putExtra(MovingActivity.TAG_MOVING_CONNECT_NAME, staConnectName.getText().toString());
				setResult(RESULT_OK, getIntent());
				InputTelActivitity.this.finish();
			}
			break;

		default:
			break;
		}
	}

	private boolean checkInput() {
		if(StringUtils.isEmpty(staConnectTel.getText())){
			showErroCustomToast(getString(R.string.station_input_tel));
			return false;
		}
		if(!TcUtil.isMobileNO(staConnectTel.getText().toString())){
			showErroCustomToast("请输入正确的电话号码");
			return false;
		}
		if(StringUtils.isEmpty(staConnectName.getText())){
			showErroCustomToast("请输入联系人");
			return false;
		}
		return true;
	}
	
}
